package yesjava;

/**
 * 演示字符串操作的常用的方法
 */
public class StringDemo {
    public static void main(String[] args) {
        String s1 = "我爱伟大.的中华人民共和国.的伟大人民";
        String s3 = s1.replaceAll("\\w{3,}", "");
        System.out.println(s3);
        //  判断一个字符串是否包含另外一个字符串

        System.out.println(( (s1!=null && s1.indexOf("共和国")!=-1)? "OK":"NO"));
//        System.out.println(( (s1!=null && s1.contains("共和国"))? "OK":"NO"));
      /*  System.out.println(s1.indexOf("伟大"));
        System.out.println(s1.lastIndexOf("伟大"));*/
       /* int index = s1.indexOf("爱伟大");
        System.out.println(index);*/

      /*  System.out.println(s1.substring(3,11));//含前不含后,返回是副本
        System.out.println(s1.replace("伟大", "可爱"));
        System.out.println(s1);*/
        System.out.println(s1.replace(".", "#"));
        System.out.println(s1.replaceAll("\\.", "#"));
        String s2 = "很开心,520520110,男,18696572966";
        String[] split = s2.split(",");
        for (String s : split) {
            System.out.println(s);
        }

        System.out.println("abcdEFG张晓晓".toLowerCase());
        System.out.println("abcdEFG张晓晓".toUpperCase());
        System.out.println("a".compareTo("a"));
        System.out.println("  呵呵 ".trim().length());




        /*int length = s1.length();
        char c = s1.charAt(6);
        System.out.println(c);
        char[] chars = s1.toCharArray();*/

//        System.out.println(length);

       /* String s2 = new String("中华人民共和国万岁ABCD");
        System.out.println(s1==s2);
        System.out.println(s1.equals(s2));
        System.out.println(s1.equalsIgnoreCase(s2));*/


    }
}
